home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1997 October: Mac OS SDK / Dev.CD Oct 97 SDK1.toast / Development Kits (Disc 1) / AppleSearch / Macintosh / AppleSearch Client API / Headers / ASClientAPI.h < prev    next >
Encoding:
C/C++ Source or Header  |  1995-01-19  |  17.6 KB  |  495 lines  |  [TEXT/MPS ]

  1. /*
  2.     File:        ASClientAPI.h
  3.  
  4.     Copyright:    Copyright Apple Computer, Inc. 1992-1994
  5.                 All rights reserved
  6.  
  7. */
  8.  
  9. #ifndef __ASCLIENTAPI__
  10. #define __ASCLIENTAPI__
  11.  
  12. //______________________________________________________________________________________________________________________
  13. //______________________________________________________ INCLUDES ______________________________________________________
  14. //______________________________________________________________________________________________________________________
  15.  
  16. #ifndef __TYPES__
  17. #include <Types.h>
  18. #endif
  19.  
  20. #ifndef __ALIASES__
  21. #include <Aliases.h>
  22. #endif
  23.  
  24.  
  25. //______________________________________________________________________________________________________________________
  26. //______________________________________________________ CONSTANTS _____________________________________________________
  27. //______________________________________________________________________________________________________________________
  28. // errors
  29.  
  30. #define    kNoError                    0
  31.  
  32. //______________________________________________________________________________________________________________________
  33. // bit-fields
  34.  
  35. #define kLogon_AutoLogonFlag        0x00000001
  36. #define kLogon_DeliverUpdateFlag    0x00000002
  37. #define kLogon_IsGuestFlag            0x00000004
  38.  
  39. //______________________________________________________________________________________________________________________
  40. // misc.
  41.  
  42. enum    IDDataType { kProcessSerialNumber, kAEAddressDescriptor, kOther };
  43.  
  44. #define    kMaximumInfoSourceLength    31
  45. #define kMaximumInfoSources            100
  46.  
  47. #define    kObjType_Reporter            1
  48. #define    kObjType_HitList            2
  49. #define kObjType_NewspaperDate        3
  50.  
  51. // #define    kObjType_Newspaper            11;
  52.  
  53. enum ASRequestKind
  54. {
  55.     kASNullRequest,                // [ 0] void request
  56.     kASEnumSourcesRequest,        // [ 1] retrieve a list of info sources
  57.     kASGetSourceInfoRequest,    // [ 2] open an existing index
  58.     kASOpenSearchRequest,        // [ 3] establish a search session
  59.     kASDoSearchRequest,            // [ 4] perform a search operation
  60.     kASGetRelatedTermsRequest,    // [ 5] expand a search term to a list of related terms
  61.     kASCloseSearchRequest,        // [ 6] close a search session
  62.     kASLogoffRequest,             // [ 7] retrieve a list of database objects
  63.     kASGetTextRequest,            // [ 8] retrieve text of an article
  64.     kASGetMatchesRequest,        // [ 9] retrieve match list of an article
  65.     kASGetArticleInfoRequest,    // [10] retrieve title and date of an article
  66.     kASGetFileRequest,            // [11] retrieve original article file
  67.     kASAddReporterRequest,        // [12] add a reporter object
  68.     kASModifyReporterRequest,    // [13] modify a reporter object
  69.     kASGetReporterRequest,        // [14] retrieve a reporter object
  70.     kASDeleteReporterRequest,    // [15] remove a reporter object
  71.     kASEnumReporterRequest,        // [16] retrieve a list of reporter objects
  72.     kASImportReporterRequest,    // [17] import a reporter object                
  73.     kASExportReporterRequest,    // [18] export a reporter object                
  74.     kASAddObjectRequest,        // [19] add a database object
  75.     kASModifyObjectRequest,        // [20] modify a database object
  76.     kASGetObjectRequest,        // [21] retrieve a database object
  77.     kASDeleteObjectRequest,        // [22] remove a database object
  78.     kASEnumObjectRequest         // [23] retrieve a list of database objects
  79. };
  80.  
  81. //______________________________________________________________________________________________________________________
  82. //_______________________________________________________ TYPEDEFS _____________________________________________________
  83. //______________________________________________________________________________________________________________________
  84.  
  85. typedef long    ASErr;                                    // standard error type
  86. typedef unsigned long int    ASLogonSessionID;            // ID of the connection to a server
  87.  
  88. //______________________________________________________________________________________________________________________
  89. //____________________________ Universal proc pointer definitions ______________________________________________________
  90. //______________________________________________________________________________________________________________________
  91.  
  92. // old way
  93. //typedef long    (*ASProcPtr)(char*, long);                // proc pointer type for completion
  94.  
  95. // new way
  96.  
  97. enum {
  98.     uppASProcInfo = kCStackBased
  99.         | RESULT_SIZE(SIZE_CODE(sizeof(long)))
  100.         | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(char*)))
  101.         | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(long)))
  102. };
  103.  
  104. #if USESROUTINEDESCRIPTORS
  105.  
  106. typedef UniversalProcPtr (*ASUPP)(char* thePointer, long theLong);
  107.  
  108. #define CallASUPP(userRoutine, thePointer, theLong) \
  109.     CallUniversalProc((UniversalProcPtr)(userRoutine), uppASProcInfo, thePointer, theLong)
  110.     
  111. #define NewASCompletionProc(userRoutine) \
  112.     (ASUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), \
  113.     uppASProcInfo, GetCurrentISA())
  114.     
  115. #else
  116.  
  117. typedef ProcPtr (*ASUPP)(char* thePointer, long theLong);
  118.  
  119. #define NewASCompletionProc(userRoutine) \
  120.     (ASUPP)((userRoutine))
  121.     
  122. #endif
  123.  
  124. //______________________________________________________________________________________________________________________
  125. //___________________________________________________ PARAMETER BLOCKS _________________________________________________
  126. //______________________________________________________________________________________________________________________
  127.  
  128. // AppleSearch Client C API param block standard header
  129.  
  130. #define ASParamBlockHeader \
  131.     long        userRefCon;                /* for caller's use */                \
  132.     ASErr        error;                    /* API call result */                \
  133.     ASUPP        completionProc;            /* ptr to a completion routine */    \
  134.     long        registrationID;            /* from ASRegister */
  135.  
  136. #if defined(powerc) || defined (__powerc)
  137. #pragma options align=mac68k
  138. #endif
  139.  
  140. struct ASUniversalPB {
  141.     ASParamBlockHeader    
  142. };
  143. typedef struct ASUniversalPB ASUniversalPB, *ASUniversalPBPtr;
  144.  
  145. //______________________________________________________________________________________________________________________
  146.  
  147. struct ASRegisterPB {
  148.     ASParamBlockHeader    
  149.     long            identifier;
  150. };
  151.  
  152. typedef struct ASRegisterPB ASRegisterPB, *ASRegisterPBPtr;
  153.  
  154. //______________________________________________________________________________________________________________________
  155.  
  156. struct ASSelectServerPB {
  157.     ASParamBlockHeader    
  158.     Ptr                defaultServer;
  159.     unsigned long    dataSize;
  160.     Ptr                dataPtr;
  161. };
  162.  
  163. typedef struct ASSelectServerPB ASSelectServerPB, *ASSelectServerPBPtr;
  164.  
  165. //______________________________________________________________________________________________________________________
  166.  
  167. struct ASNewLogonPB {
  168.     ASParamBlockHeader
  169.     unsigned long    flags;
  170.     char*            zoneStr;        // null terminated
  171.     char*            serverStr;        // null terminated
  172.     char*            userNameStr;    // null terminated
  173.     char*            passwordStr;    // null terminated
  174. };
  175.  
  176. typedef struct ASNewLogonPB ASNewLogonPB, *ASNewLogonPBPtr;
  177.  
  178.  
  179. //______________________________________________________________________________________________________________________
  180.  
  181. struct ASLogonPB {
  182.     ASParamBlockHeader    
  183.     unsigned long    flags;                    // -> deliverUpdate, autoLogon; <- isGuest
  184.     unsigned long    dataSize;                // ->
  185.     Ptr                dataPtr;                // ->
  186.     unsigned long    defaultUserNameLength;    // ->
  187.     char*            defaultUserNameString;    // ->
  188.     unsigned long    serverNameLength;        // <-
  189.     char*            serverNameString;        // <-
  190. };
  191.  
  192. typedef struct ASLogonPB ASLogonPB, *ASLogonPBPtr;
  193.  
  194. //______________________________________________________________________________________________________________________
  195.  
  196. struct ASLogoffPB {
  197.     ASParamBlockHeader    
  198.     Boolean            forceLogoff;
  199. };
  200.  
  201. typedef struct ASLogoffPB ASLogoffPB, *ASLogoffPBPtr;
  202.  
  203. //______________________________________________________________________________________________________________________
  204.  
  205. struct ASSearchSessionPB {
  206.     ASParamBlockHeader    
  207.     long            searchSessionID;
  208. };
  209.  
  210. typedef struct ASSearchSessionPB ASSearchSessionPB, *ASSearchSessionPBPtr;
  211.                                                         
  212. //______________________________________________________________________________________________________________________
  213.  
  214. struct ASDBObjectInfo {
  215.     long            dbObjectID;
  216. //    Str31            dbObjectName;
  217.     long            dbObjectFlags;
  218.     unsigned long    dbObjectNameLength;
  219.     char*            dbObjectNameString;
  220. };
  221.  
  222. typedef struct ASDBObjectInfo ASDBObjectInfo, *ASDBObjectInfoPtr;
  223.                                                 
  224.  
  225. struct ASEnumeratePB {
  226.     ASParamBlockHeader    
  227.     long                dbObjectType;            //    ->
  228.     unsigned long        numberOfDBObjects;        //    ->        number of objects in the list
  229.     ASDBObjectInfoPtr    dbObjectList;            //    ->        an array of ASDBObjectInfo structures
  230. };
  231.  
  232. typedef    struct ASEnumeratePB ASEnumeratePB, *ASEnumeratePBPtr;
  233.  
  234. //______________________________________________________________________________________________________________________
  235.                                                         
  236. struct ASHitInfo {
  237.     long            articleID;
  238.     long            modDate;
  239.     unsigned long    fileSize;
  240.     unsigned long    rank;
  241.     unsigned long    titleLength;
  242.     char*            titleString;
  243. };
  244.  
  245. typedef struct ASHitInfo ASHitInfo, *ASHitInfoPtr;
  246.  
  247.  
  248. struct ASSearchPB {
  249.     ASParamBlockHeader    
  250.     long            searchSessionID;
  251.     long            sourceID;
  252.     unsigned long    queryLength;
  253.     char*            queryString;            // c string, null terminated
  254.     unsigned long    minimumRank;
  255.     unsigned long    maximumHits;            // NOTE: who allocates the memory for hits?
  256.     long            earliestModDate;
  257.     long            searchType;
  258.     long            searchID;
  259.     unsigned long    numberOfHitsReturned;
  260.     unsigned long    totalNumberOfHits;
  261.     ASHitInfoPtr*    hitList;                // packed array of ASHitPtrs
  262. };
  263.  
  264. typedef struct ASSearchPB ASSearchPB, *ASSearchPBPtr;
  265.  
  266. //______________________________________________________________________________________________________________________
  267.  
  268. struct ASGetArticleInfoPB {
  269.     ASParamBlockHeader    
  270.     long            sourceID;                // <-
  271.     long            articleID;                // <-
  272.     long            modDate;                // ->
  273.     unsigned long    size;                    // ->
  274.     unsigned long    titleLength;            // ->
  275.     char*            titleString;            // ->
  276. };
  277.  
  278. typedef    struct ASGetArticleInfoPB ASGetArticleInfoPB, *ASGetArticleInfoPBPtr;
  279.                                                         
  280. //______________________________________________________________________________________________________________________
  281.  
  282. struct ASGetArticleTextPB {
  283.     ASParamBlockHeader    
  284.     long            searchSessionID;
  285.     long            sourceID;
  286.     long            articleID;
  287.     unsigned long    startOffset;
  288.     unsigned long    length;
  289.     Handle            text;
  290. };
  291.  
  292. typedef struct ASGetArticleTextPB    ASGetArticleTextPB, *ASGetArticleTextPBPtr;
  293.  
  294. //______________________________________________________________________________________________________________________
  295.  
  296. struct ASGetArticleMatchesPB {
  297.     ASParamBlockHeader    
  298.     long            searchSessionID;
  299.     long            sourceID;
  300.     long            articleID;
  301.     unsigned long    startOffset;
  302.     unsigned long    length;
  303.     unsigned long    numberOfHiliteInfoRecs;
  304.     long*            hiliteInfo; // points to the first long of array of hiliteinfoRecs
  305. };
  306.  
  307. typedef struct ASGetArticleMatchesPB    ASGetArticleMatchesPB, *ASGetArticleMatchesPBPtr;
  308.  
  309. //______________________________________________________________________________________________________________________
  310.  
  311. struct ASHiliteInfoRec {
  312.     unsigned long    offset;
  313.     unsigned long    length;
  314. };
  315.  
  316. typedef struct ASHiliteInfoRec ASHiliteInfoRec, *ASHiliteInfoRecPtr;
  317.  
  318. //______________________________________________________________________________________________________________________
  319.  
  320. struct    ASGetOriginalFilePB {
  321.     ASParamBlockHeader    
  322.     long            sourceID;
  323.     long            articleID;
  324.     long            flags;                    // 1 = origional file; 2 = alias to file
  325.     FSSpec            fileDestination;
  326.     AliasHandle        alias;
  327. };
  328.  
  329. typedef struct ASGetOriginalFilePB ASGetOriginalFilePB, *ASGetOriginalFilePBPtr;
  330.                                                         
  331. //______________________________________________________________________________________________________________________
  332.  
  333. struct ASReporterPB {
  334.     ASParamBlockHeader    
  335.     long            reporterID;                //    
  336.     unsigned long    nameLength;                // 
  337.     char*            nameString;                //    
  338.  
  339.     // search parameters
  340.     unsigned long    queryLength;            //    
  341.     char*            queryString;            // c string, null terminated
  342.     unsigned long    minimumRank;            //    
  343.     unsigned long    maximumHits;            //    
  344.     long            earliestModDate;        //    
  345.     long            earliestIndexDate;        //    
  346.     unsigned long    numberOfSources;        //    
  347.     long*            sourceList;                //    
  348.     
  349.     // scheduling info
  350.     unsigned long    deliveryDays;            //    
  351.     unsigned long    deliveryTime;            //    
  352.     long            deliveryFlags;            //    
  353.     unsigned long    deliveryDirLength;        //    
  354.     AliasPtr        deliveryDir;            //    
  355. };
  356.  
  357. typedef    struct ASReporterPB ASReporterPB, *ASReporterPBPtr;
  358.                                                         
  359. //______________________________________________________________________________________________________________________
  360.  
  361. struct ASDBObjectPB {
  362.     ASParamBlockHeader    
  363.     long            dbObjectType;
  364.     ASDBObjectInfo    dbObjectInfo;
  365.     long            sourceID;                // used only if type is hit list
  366.     unsigned long    dbObjectDataSize;
  367.     Ptr                dbObjectData;
  368. };
  369.  
  370. typedef struct ASDBObjectPB ASDBObjectPB, *ASDBObjectPBPtr;
  371.  
  372. //______________________________________________________________________________________________________________________
  373.  
  374. struct ASImportExportPB {
  375.     ASParamBlockHeader    
  376.     FSSpec            reporterFile;            //    
  377.     long            reporterID;                //    
  378.     unsigned long    nameLength;
  379.     char*            nameString;
  380. };
  381.  
  382. typedef    struct ASImportExportPB ASImportExportPB, *ASImportExportPBPtr;
  383.                                                         
  384. //______________________________________________________________________________________________________________________
  385.  
  386. struct ASGetRelatedTermsPB {
  387.     ASParamBlockHeader    
  388.     long            sourceID;                // <-
  389.     unsigned long    queryLength;            // <-
  390.     char*            queryString;            // <-
  391.     unsigned long    maximumTerms;            // <-
  392.     unsigned long    numberOfTerms;            // ->
  393.     StringPtr*        termList;                // ->
  394. };
  395.  
  396. typedef    struct ASGetRelatedTermsPB ASGetRelatedTermsPB, *ASGetRelatedTermsPBPtr;
  397.                                                         
  398. //______________________________________________________________________________________________________________________
  399.  
  400. struct ASGetSourceInfoPB {
  401.     ASParamBlockHeader    
  402.     long            sourceID;                // <-
  403.     unsigned long    numberOfDocsIndexed;    // ->
  404.     unsigned long    indexFileSize;            // ->
  405.     unsigned long    textSizeIndexed;        // ->
  406.     unsigned long    lastIndexedDate;        // ->
  407.     Str255            description;            // ->
  408. };
  409.  
  410. typedef    struct ASGetSourceInfoPB ASGetSourceInfoPB, *ASGetSourceInfoPBPtr;
  411.                                                         
  412. #if defined(powerc) || defined(__powerc)
  413. #pragma options align=reset
  414. #endif
  415.  
  416. //______________________________________________________________________________________________________________________
  417. //_________________________________________________ FUNCTION PROTOTYPES ________________________________________________
  418. //______________________________________________________________________________________________________________________
  419.  
  420. //______________________________________________________________________________________________________________________
  421. // "House keeping" routines
  422.  
  423. #ifdef __cplusplus
  424. extern "C" {
  425. #endif
  426.  
  427. extern void     ASInitialize( void );                                            // must be called to initialize internal globals
  428. extern void     ASQuit( void );                                                    // call it when your application is ready to quit
  429. extern ASErr    ASDoIdle( void );                                                // must be called in each waitNexEvent loop
  430. extern ASErr    ASRegister(    ASRegisterPBPtr pb );
  431. extern ASErr    ASUnregister( ASRegisterPBPtr pb );
  432. extern ASErr    ASSelectServer( ASSelectServerPBPtr pb );
  433. extern ASErr    ASLogon( ASLogonPBPtr pb );
  434. extern ASErr    ASNewLogon( ASNewLogonPBPtr pb );            // may not work in later versions of the system! NOT supported
  435.                                                             // it is here for your convenience only. It was only tested
  436.                                                             // with system 7.5 and earlier
  437. extern ASErr    ASLogoff( ASLogoffPBPtr pb );
  438.  
  439. //______________________________________________________________________________________________________________________
  440. // Search routines
  441.  
  442. extern ASErr    ASOpenSearchSession( ASSearchSessionPBPtr pb, Boolean async );
  443. extern ASErr    ASCloseSearchSession( ASSearchSessionPBPtr pb, Boolean async );
  444. extern ASErr    ASSearch( ASSearchPBPtr pb, Boolean asynch );
  445.                                                         
  446. //______________________________________________________________________________________________________________________
  447. // Data retrieval routines
  448.  
  449. extern ASErr    ASEnumerateSources( ASEnumeratePBPtr pb, Boolean async );
  450. extern ASErr    ASGetArticleText( ASGetArticleTextPBPtr pb, Boolean asynch );
  451. extern ASErr    ASGetArticleMatches( ASGetArticleMatchesPBPtr pb, Boolean asynch );
  452. extern ASErr    ASGetArticleInfo( ASGetArticleInfoPBPtr pb, Boolean async );
  453. extern ASErr    ASGetOriginalFile( ASGetOriginalFilePBPtr pb, Boolean asynch );
  454. extern ASErr    ASGetRelatedTerms( ASGetRelatedTermsPBPtr pb, Boolean async );
  455.  
  456. //______________________________________________________________________________________________________________________
  457. // Reporter routines
  458.  
  459. extern ASErr    ASAddReporter( ASReporterPBPtr pb, Boolean async );
  460. extern ASErr    ASModifyReporter( ASReporterPBPtr pb, Boolean async );
  461. extern ASErr    ASGetReporter( ASReporterPBPtr pb, Boolean async );
  462. extern ASErr    ASDeleteReporter( ASReporterPBPtr pb, Boolean async );
  463. extern ASErr    ASEnumerateReporters( ASEnumeratePBPtr pb, Boolean async );
  464.  
  465. extern ASErr    ASImportReporter( ASImportExportPBPtr pb, Boolean async );
  466. extern ASErr    ASExportReporter( ASImportExportPBPtr pb, Boolean async );
  467.  
  468. //______________________________________________________________________________________________________________________
  469. // DBObject routines
  470.  
  471. extern ASErr    ASAddDBObject( ASDBObjectPBPtr pb, Boolean async );
  472. extern ASErr    ASModifyDBObject( ASDBObjectPBPtr pb, Boolean async );
  473. extern ASErr    ASGetDBObject( ASDBObjectPBPtr pb, Boolean async );
  474. extern ASErr    ASDeleteDBObject( ASDBObjectPBPtr pb, Boolean async );
  475. extern ASErr    ASEnumerateDBObjects( ASEnumeratePBPtr pb, Boolean async );
  476.  
  477. //______________________________________________________________________________________________________________________
  478. //__________________________________________________ UTILITY FUNCTIONS _________________________________________________
  479. //______________________________________________________________________________________________________________________
  480. // Bogart <-> standard Mac time conversion routines
  481.  
  482. typedef long NewDateTimeCode;
  483.  
  484. extern pascal NewDateTimeCode    MacToNewDateTime(unsigned long theMacTime);
  485. extern pascal unsigned long    NewDateTimeToMacTime(NewDateTimeCode theNewDateTime);
  486.  
  487. //______________________________________________________________________________________________________________________
  488.  
  489. #ifdef __cplusplus
  490. }
  491. #endif
  492.  
  493. #endif    // __ASCLIENTAPI__
  494.  
  495.